//
//  DatePickVC.m
//  first
//
//  Created by 毕小强 on 16/12/12.
//  Copyright © 2016年 毕小强. All rights reserved.
//

#import "DatePickVC.h"

@interface DatePickVC ()
@property(nonatomic,strong)UIDatePicker *datePick1View;
@property(nonatomic,strong)UIDatePicker *datePick2View;
@end

@implementation DatePickVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.datePick1View = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight/2.0)];
    self.datePick1View.datePickerMode = UIDatePickerModeDate;
    self.datePick1View.locale = [NSLocale localeWithLocaleIdentifier:@"zh"];
    [self.datePick1View addTarget:self action:@selector(rollAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_datePick1View];
    
    self.datePick2View = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_datePick1View.frame), kScreenWidth, kScreenHeight/2.0)];
    self.datePick2View.datePickerMode = UIDatePickerModeDate;
    self.datePick2View.locale = [NSLocale localeWithLocaleIdentifier:@"zh"];
    [self.datePick2View addTarget:self action:@selector(rollActionT:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_datePick2View];
}
-(void)rollAction:(UIDatePicker*)sender{
    NSDateFormatter *formatter = [NSDateFormatter new];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    NSLog(@"%@",[formatter stringFromDate:sender.date]);
    [self.datePick2View setDate:sender.date];
}
-(void)rollActionT:(UIDatePicker*)sender{
    NSDateFormatter *formatter = [NSDateFormatter new];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    NSLog(@"%@",[formatter stringFromDate:sender.date]);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
